package equipment;

import java.awt.*;
import java.awt.event.*;
import main.*;
import java.util.ArrayList;

public class Shield extends Equipment {
	
	public Shield() {
		options = new Choice();
		options.setName("Equipment Options");
		options.add("No Shielding");
		options.add("Shielding");
	}
	
	public void applyOptions () {
		if (options.getSelectedItem().equals("Shielding")) {
			owner.battleDice = owner.attacks*2;
			owner.woundDice = 0;
			if (owner.army == 0) {
				for (Unit u : owner.battle.goodUnits) {
					if (u.hasEquipment(new Shield()))
						u.battleDice = u.attacks*2;
					else
						u.battleDice = 0;
					u.woundDice = 0;
					u.supporters = new ArrayList<Unit>();
				}
			}
		}
	}
	
	public void equipTo(Unit u) {
		this.owner = u;
		u.defense = u.defense + 1;
	}
}